const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database({
  throwOnNotFound: true
})
const _ = db.command;
const $ = db.command.aggregate
const globalConfig = require('../../config/index')

module.exports = async (event, context, root) => {
  const {
    OPENID
  } = cloud.getWXContext();
  // 验证该接口是否需要验证注册
  let parame = event.data;

//   try {
	var result = await db.collection('caipiao_log').where({
        draw_number: parame.draw_number,
	}).update({
		data:{
			winning_numbers:parame.winning_numbers
		}
	})

    var res = {
      errcode: 200,
      msg: '操作成功！',
      result: result,
      success: true,
      timestamp: new Date().getTime()
    }
//   } catch (error) {
//     var error_type = globalConfig.common.error_type(error.errCode);
//     var res = {
//       errcode: 404,
//       error: error,
//       msg: error_type.type,
//       result: error,
//       success: false,
//       timestamp: new Date().getTime()
//     }
//   }
  return res;
}
